package com.example.droolstool.util;

import com.example.droolstool.module.DrlMessageModule;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.Maps;

import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * @Author 赵云龙
 * @Date 2020/6/26
 * @Description TODO
 */

public class CacheUtil {


    private final static long maximumSize = 20;
    /**
     * 最大20个，过期时间为1天
     */



    private Cache<String, Map<String, DrlMessageModule>> cache = CacheBuilder.newBuilder().maximumSize(maximumSize)
            .expireAfterWrite(1, TimeUnit.DAYS).build();


//    public Map<String, DrlMessageModule> getById(String id) {
//        return cache.get(id, cacheValue ->{
//          Map<String, DrlMessageModule> result = Maps.newHashMap();
//
//        });
//    }

}
